<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			/* 
			function sub(){
				let number1 = document.getElementById("number1").value-0
				let number2 = document.getElementById("number2").value-0
				let number3 = number1-number2
				document.getElementById("number3").value = number3.toFixed(15)-0
			}
			function add(){
				let number1 = document.getElementById("number1").value-0
				let number2 = document.getElementById("number2").value-0
				let number3 = number1+number2
				document.getElementById("number3").value = number3.toFixed(15)-0
			}
			function mulcal
				let number1 = document.getElementById("number1").value-0
				let number2 = document.getElementById("number2").value-0
				let number3 = number1*number2
				document.getElementById("number3").value = number3.toFixed(15)-0
			}
			function div(){
				let number1 = document.getElementById("number1").value-0
				let number2 = document.getElementById("number2").value-0
				if(isNaN(number1)||isNaN(number2)){
					document.getElementById("number3").value = "只能输入数字进行运算"
					return
				}
				if(number2 == 0){
					document.getElementById("number3").value = "除数不能为零"
					return
				}
				let number3 = number1/number2
				document.getElementById("number3").value = number3.toFixed(15)-0
			} 
			*/
			function cal(op){//形参无需声明
				let number1 = document.getElementById("number1").value
				let number2 = document.getElementById("number2").value
				let number3 = eval(number1+op+number2)
				if(isNaN(number1)||isFinite(number3){
					document.getElementById("number3").value = "只能输入数字进行运算"
					return
				}
				document.getElementById("numer3").value = number3.toFixed(15)-0;
			}
		</script>
	</head>
	<body>
		第一个数：<input type="text" id="number1" /><br>
		第二个数：<input type="text" id="number2" /><br>
		<button onclick="cal('+')">+</button>
		<button onclick="cal("-")">-</button>
		<button onclick="cal('*')">*</button>
		<button onclick="cal('/')">/</button><br>
		计算结果：<input type="text" id="number3" /><br>
	</body>
</html>

